package com.cat.twoPointerTechnique;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/longest-substring-of-all-vowels-in-order/
 * @create 2025/8/8 20:27
 * @since JDK17
 */

public class Solution27 {
    static char[] h = new char[]{'a', 'e', 'i', 'o', 'u'};
    public int longestBeautifulSubstring(String word) {
        int ans = 0, n = word.length(), start, last;
        for (int i = 0, j = 0; i < n; ) {
            last = i;
            for (j = 0; j < 5; j++) {
                start = i;
                while (i < n && h[j] == word.charAt(i)) {
                    i++;
                }
                if (start == i) {
                    break;
                }
            }
            if (j == 5) {
                ans = Math.max(ans, i - last);
            }
        }
        return ans;
    }
}
